﻿using System;
using System.IO;
using System.Text.Json;

namespace Launcher;

public class AppConfig
{
    public static AppConfig Instance { get; private set; }
    public string AppName { get; set; } = "Launcher";
    public string DefaultCachePath { get; set; } = "Cache" + Path.DirectorySeparatorChar;
    public string RequestInfoUrl { get; set; }= string.Empty;

    public static void Load()
    {
        AppConfig? config = null;
        try
        {
            config = JsonSerializer.Deserialize<AppConfig>(File.ReadAllText("config.json"));
        }
        catch (Exception e)
        {
            Console.Error.WriteLine(e);
        }
        
        Instance = config ?? new();
    }
}